Frontend Forever App
We have a mobile app for you to download and use. And you can unlock many features in the app.
Get it now
Intall Later
Run
HTML
CSS
Javascript
Output
Math Calculator
Calculate
body { font-family: sans-serif; } #calculator { width: 300px; margin: 0 auto; } #expression { width: 100%; height: 20px; border: 1px solid black; padding: 5px; } #calculate { width: 100px; height: 30px; background-color: #009688; color: white; border: none; cursor: pointer; } #result { font-size: 16px; font-weight: bold; }
var expression = ""; var result = ""; function calculate() { expression = document.getElementById("expression").value; result = eval(expression); document.getElementById("result").innerHTML = result; } document.getElementById("calculate").addEventListener("click", calculate);